import { Dialog } from 'vant';
import axios from 'axios'
import {baseApi} from '../config/env/index';
axios.defaults.baseURL = baseApi
axios.defaults.withCredentials = true; //是否带cookie
axios.defaults.headers['Content-Type'] = 'application/json';
axios.interceptors.response.use(response => {
  if (response.data.code !== 200) {
    Dialog.alert({
      title: '错误代码' + response.data.code,
      message: response.data.errMsg || '请求失败 未知错误 •﹏•'
    })
  }
  return response
}, err => {
  Dialog.alert({
    title: '请求异常',
    message: '请求失败 未知错误 •﹏•'
  });
  return Promise.reject(err)
});
export default axios
